package com.gwz.util;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

public class HttpUtil {
	
	 /**
     * httpclient发送get请求
     * @param url
     * @param data
     * @return
     */
    public static void sendGet(String url) throws Exception {
        HttpClient httpclient = new HttpClient();
        url += "?timer=" + System.currentTimeMillis();
        GetMethod method = new GetMethod(url);
        method.setRequestHeader("Connection", "close");
        method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
        httpclient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);//请求超时时长
        try {
            httpclient.executeMethod(method);
        } catch (Exception e) {
            throw new Exception("发送http=== " + url + " , post请求发生系统异常===", e);
        } finally {
            if (method != null) {
                method.abort();
                method.releaseConnection();
            }
        }
    }
}
